home *** CD-ROM | disk | FTP | other *** search
- #ifndef _PROCESSSTATS_H_
- #define _PROCESSSTATS_H_
- /*
- * $RCSfile: processStats.h,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:46 $
- */
- /*
- * stats.h
- *
- * Class definition for the stats class.
- * Member functions are defined in stats.c
- */
- #ifndef _stats
- #define _stats
-
- #include <stdio.h>
- #include "sysdefs.h"
- #include <sys/resource.h>
-
- #ifdef hpux
- #include <sys/syscall.h>
- #define getrusage(a, b) syscall(SYS_GETRUSAGE, a, b)
- #endif /* hpux */
-
- /*
- * Stats objects are meant to be used as follows:
- *
- * statsObj.Start();
- * section of code for which stats are being gathered
- * statsObj.Stop();
- * examine gathered statistics
- *
- * Note that member functions marked as unimplmented return zero.
- * They are unimplemented because Mach has yet to support the
- * gathering of the required statistics.
- * Mach will supposedly provide support in the near future, however.
- */
-
-
- /*
- * Stats for Unix processes.
- */
- class ProcessStats {
- struct timeval time1; /* gettimeofday() buffer */
- struct timeval time2; /* gettimeofday() buffer */
- struct rusage rusage1; /* getrusage() buffer */
- struct rusage rusage2; /* getrusage() buffer */
-
- int smPagesRead1;
- int smPagesRead2;
- int smPagesWrite1;
- int smPagesWrite2;
-
- public:
- void Start(); /* start gathering stats */
- void Stop(); /* stop gathering stats */
- float RealTime(); /* elapsed real time in micro-seconds */
- float UserTime(); /* elapsed user time in micro-seconds */
- float SystemTime(); /* elapsed system time in micro-seconds */
- int PageReclaims(); /* page reclaims */
- int PageFaults(); /* page faults */
- int Swaps(); /* swaps */
- int PageIns(); /* page-ins */
- int PageOuts(); /* page-outs */
- int smPagesRead(); /* pages read from sm */
- int smPagesWrite(); /* pages written to sm */
- void PrintStatsHeader(FILE *f);
- void PrintStats(FILE *f, char* prefix);
- };
-
- /*
- * C library externs.
- */
- #ifndef getrusage
- extern "C" int getrusage(int, struct rusage*);
- #endif
- extern "C" int gettimeofday(struct timeval*, struct timezone*);
-
- #endif _stats
- #endif /* _PROCESSSTATS_H_ */
-